package com.night.icm.service.business.mapper;

import com.night.icm.model.business.StudentCourseGradeGatherDTO;
import com.night.icm.persistence.business.entity.StudentCourseGradeGather;
import org.mapstruct.*;

import java.util.List;

/**
 * StudentCourseGradeGatherMapper
 *
 * @author Liao ZhiYong
 * @date 2020/2/16
 */
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface StudentCourseGradeGatherMapper {
    /**
     * DTO转实体
     *
     * @param dto DTO
     * @return 实体
     */
    StudentCourseGradeGather toEntity(StudentCourseGradeGatherDTO dto);

    /**
     * 实体转DTO--供findById使用
     *
     * @param entity 实体
     * @return DTO
     */
    StudentCourseGradeGatherDTO toDTO(StudentCourseGradeGather entity);

    /**
     * 实体转DTO--供分页查询使用
     *
     * @param save 实体
     * @return DTO
     */
    @Named("toDtoByPage")
    StudentCourseGradeGatherDTO toDtoByPage(StudentCourseGradeGather save);

    /**
     * 实体集转为DTO集
     *
     * @param entities 实体集
     * @return DTO集
     */
    @IterableMapping(qualifiedByName = "toDtoByPage")
    List<StudentCourseGradeGatherDTO> toList(List<StudentCourseGradeGather> entities);

    /**
     * 更新一个已经存在的实体数据
     *
     * @param dto    存在的DTO
     * @param entity 更新后的实体
     */
    void updateEntity(StudentCourseGradeGatherDTO dto, @MappingTarget StudentCourseGradeGather entity);
}
